import * as tslib_1 from "tslib";
import { observable, action } from "mobx";
import { areaOptions } from "../utils/area";
import { LoadHoc, loading } from "../hoc/loadHoc";
let AreaStore = class AreaStore extends LoadHoc {
  constructor() {
    super(...arguments);
    /**
     * 获取所有省份信息
     */
    this.allProvince = [];
    /**
     * 获取所有市区信息
     */
    this.allCity = [];
    /**
     * 获取所有区信息
     */
    this.allDistract = [];
  }
  async getAllProvinceFromLocal(params) {
    const { callBack } = params;
    let temArr = [];
    // console.log(areaOptions)
    await areaOptions.map(province => {
      temArr.push({
        value: province.value,
        label: province.label
      });
    });
    this.allProvince = temArr;
    callBack && callBack(temArr);
  }
  async getAllCityFromLocal(params) {
    const { index, callBack } = params;
    let temArr = [];
    if (index === -1) {
      await areaOptions.map(province => {
        province.children.map(city => {
          temArr.push({
            value: city.value,
            label: city.label
          });
        });
      });
    } else {
      temArr = areaOptions[index]['children'];
    }
    this.allCity = temArr;
    callBack && callBack(temArr);
  }
  async getAllDistractFromLocal(params) {
    const { indexProvince, indexCity, callBack } = params;
    let temArr = [];
    if (indexCity === -1) {
      await areaOptions.map(province => {
        province.children.map(city => {
          city.children.map(distract => {
            temArr.push({
              value: distract.value,
              label: distract.label
            });
          });
        });
      });
    } else {
      temArr = areaOptions[indexProvince]['children'][indexCity]['children'];
    }
    this.allDistract = temArr;
    callBack && callBack(temArr);
  }
};
export { AreaStore as default };

tslib_1.__decorate([observable], AreaStore.prototype, "allProvince", undefined);
tslib_1.__decorate([loading, action], AreaStore.prototype, "getAllProvinceFromLocal", null);
tslib_1.__decorate([observable], AreaStore.prototype, "allCity", undefined);
tslib_1.__decorate([loading, action], AreaStore.prototype, "getAllCityFromLocal", null);
tslib_1.__decorate([observable], AreaStore.prototype, "allDistract", undefined);
tslib_1.__decorate([loading, action], AreaStore.prototype, "getAllDistractFromLocal", null);